program ncmp;

uses
  testlib, sysutils;

Var board: array[0..9, 0..9] of integer;
    x0,y0,n,m,x,y,dx,dy,i,j : integer;
    s:string;
    empty:boolean;
// inf - input
// ouf - ответ участника
// ans - ответ жюри
begin
  n := inf.readlongint;
  s := inf.readword(blanks,blanks);
  x0 := ord(s[1])-ord('a') + 1;
  y0 := ord(s[2])-ord('0');
  for i:=1 to 8 do
      for j:=1 to 8 do 
        board[i,j] := 0;
  for i:=1 to n do
    begin
      s := inf.readword(blanks,blanks);
      x := ord(s[1])-ord('a') + 1;
      y := ord(s[2])-ord('0');
      board[x,y] :=1;
    end;
  m:=0;
  s := ans.readword(blanks,blanks);
  if s='No' then
  begin
     s := ouf.readword(blanks,blanks);
     if s = 'No' then  quit(_ok, 'No solution')
                 else  quit(_wa, ' Wrong answer') 
  end;
  while not ouf.seekeof do
  begin
    inc(m);
    s := ouf.readword(blanks,blanks);
    if (length(s)<>2) then quit(_wa, ' Wrong location');
    if not(s[1] in ['a'..'h']) or not(s[2] in ['1'..'8']) then quit(_wa, ' Wrong location');
    x := ord(s[1])-ord('a') + 1;
    y := ord(s[2])-ord('0');
    if (x<>x0) and (y<>y0) and (x+y<>x0+y0) and (x-y<>x0-y0) then quit(_wa, ' Illegal move');
    if board[x,y]<>1 then quit(_wa, ' Next location is empty');
    board[x,y]:=0;
    dx:=x-x0; dy:=y-y0;
    empty:=true;
    if dx = 0 then  
       if dy>0 then begin for i:=y0 to y do if board[x,i]=1 then empty:=false; end
	       else begin for i:=y to y0 do if board[x,i]=1 then empty:=false; end;
    if dy = 0 then  
       if dx>0 then begin for i:=x0 to x do if board[i,y]=1 then empty:=false; end
	       else begin for i:=x to x0 do if board[i,y]=1 then empty:=false; end;
    if dx*dy > 0 then 
       if dx>0 then begin for i:=x0 to x do if board[i,y0+i-x0]=1 then empty:=false; end
               else begin for i:=x to x0 do if board[i,y+i-x]=1 then empty:=false; end;  
    if dx*dy < 0 then 
       if dx>0 then begin for i:=x0 to x do if board[i,y0-i+x0]=1 then empty:=false; end
               else begin for i:=x to x0 do if board[i,y-i+x]=1 then empty:=false; end;  
    if not(empty) then  quit(_wa, ' Line is not empty');
    x0 := x; y0 := y;
  end;
  if (m<>n) then quit(_wa, ' Wrong number of moves');
  quit(_ok, inttostr(n) + ' moves');
end.
